package com.example.javase.annotation;

import java.lang.reflect.Method;

/**
 * Created by sk-ziconglu on 2017/5/9.
 */
public class ProcessorTest {

    public static void process(String clazz) throws ClassNotFoundException {
        int passed = 0, failed = 0;
        for (Method method : Class.forName(clazz).getMethods()) {
            if (method.isAnnotationPresent(Testable.class)) {
                try {
                    method.invoke(null);
                    passed++;
                }
                catch (Exception e) {
                    System.out.println("method " + method + " error, exception:" + e.getCause());
                    failed++;
                }
            }
        }

        System.out.println("passed " + passed + ", failed " + failed);

    }
}
